const DB = require('../../../../utils/db')
/**
 * GET
 * 获取某动态的评论列表
 */
module.exports = async (ctx) => {
  let dynamicId = ctx.request.query.dynamicId

  // 回复帖子
  const res = await DB.query(
    `select dc.userid, replyUser.username as replyName, u.username, dc.createTime, dc.commentContent,u.avatar from  dynamic_comment dc join user u on dc.userid=u.userid
left JOIN user replyUser on replyUser.userid = dc.toReply where(dynamicId='${dynamicId}') order by  dc.id`
  )
  // res.forEach(item => {
  //   item.toReply
  // });
  // const res1 = await DB.query(`
  // select username from user where userid=${}
  // `)
  ctx.body = {
    code: 0,
    data: res,
  }
}
